package com.wiscamp.ninechapters.problems.math;

import lombok.Data;
import lombok.EqualsAndHashCode;


/**
 * 三角形的表示
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class LatexTriangleDenote extends LatexGeometryDenote {
    /**
     * 起始顶点
     */
    private char startVertex;

    /**
     * 中间顶点
     */
    private char middleVertex;

    /**
     * 结束顶点
     */
    private char endVertex;

    public String getLatex() {
        return "\\triangle{" + startVertex + middleVertex + endVertex + "}";
    }

    public LatexTriangleDenote(char startVertex, char middleVertex, char endVertex) {
        this.startVertex = startVertex;
        this.middleVertex = middleVertex;
        this.endVertex = endVertex;
    }

    public LatexTriangleDenote(String content) {
        var text = content.replace("\\triangle{", "").replace("}", "");
        var chars = text.toCharArray();
        if (chars.length == 3) {
            this.startVertex = chars[0];
            this.middleVertex = chars[1];
            this.endVertex = chars[2];
        }
    }
}
